﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using System.IO;
using Microsoft.Office.Interop.Excel;

namespace WpfApplication2
{
    class MainProcess
    {
        public Workbook CreateWorkBook()
        {
            ExcelOperation excel = new ExcelOperation();
            AdoOperation operation = new AdoOperation();
            Microsoft.Office.Interop.Excel.Application xlApp = excel.CreateExcel();
            Workbook wb = excel.CreateWorkBook(xlApp);
            
            return wb;
        }
        public void PerformOperation(Workbook wb ,string CommandText,string SheetName,string ConnString)
        {
            System.Data.DataTable table = new System.Data.DataTable();
            ExcelOperation excel = new ExcelOperation();
            AdoOperation operation = new AdoOperation();
            try
            {
                Worksheet ws = excel.CreateWorkSheet(wb, SheetName);
                table = operation.GetTableData(CommandText, ConnString);
                excel.WriteExcel(ws, table);
            }
            catch (Exception ex)
            {
                
                throw ex;
            }
            
           
        }
    }
}
